﻿var hourModal = new Vue({
    el: '#hourModal',
    data: {
        sourceName: "",
        quantityName: "",
        date: 1,
        hour:0,
        hourDataCalcMode: 5,
        hourDataSource: null,
        hourDataSource2: null,
        sourceSource: null,
        quantitySource: null,
    },
    methods: {
        confirm: function () {
            $(this.$refs.hourModal).modal('hide');
            var functionStr = "=PMEGetHourData(" + this.sourceName + ", " + this.quantityName + ", \"" + this.date + "\", " + this.hour + ", " + this.hourDataCalcMode + ")";
            ReportDesignerStaticClass.SetActiveCellValue(spreadsheet, functionStr);
        }
    },
    created: function () {
        var dataModel = new dmyDataModelClass();
        this.hourDataSource = dataModel.getHourDataSource();
        this.hourDataSource2 = dataModel.getHourDataSource2();
        var sourceQuantity = new sourceQuantityClass();
        var that = this;
        sourceQuantity.getsource(function (res) {
            that.$nextTick(function () {
                if (res != null && res != undefined && res.length > 0)
                    for (var i = 0; i < res.length; i++) {
                        res[i] = { id: res[i].Id, name: res[i].Name };
                    }
                this.sourceSource = res;
            });
        });
        sourceQuantity.getquantity(function (res) {
            that.$nextTick(function () {
                if (res != null && res != undefined && res.length > 0)
                    for (var i = 0; i < res.length; i++) {
                        res[i] = { id: res[i].Id, name: res[i].Name };
                    }
                this.quantitySource = res;
            });
        });
        var myDate = new Date();
        this.date = ReportViewerHelpStaticClass.DateFormat(myDate, "yyyy-MM-dd");
        //this.date = myDate;
    },
})